package com.service.bank.controller;

import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.client.model.pojo.bank.ArElectronic;
import com.client.model.pojo.user.ArUser;
import com.client.model.vo.common.Result;
import com.client.model.vo.common.ResultCodeEnum;
import com.service.bank.service.ArElectronicService;
import io.swagger.v3.oas.annotations.Operation;
import org.aspectj.weaver.ast.Var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：刘文举
 * @DateTime： 2024/4/10 19:17
 * @PackageName: com.service.bank.controller
 * @ClassName: ElectronicController
 */
@RestController
@RequestMapping("airui/api/electronic")
public class ElectronicController {


    @Autowired
    private ArElectronicService arElectronicService;

    @Autowired
    private RedisTemplate<String,String> redisTemplate;


    @GetMapping("/getAssPrice")
    @Operation(summary = "获取二类账户信息")
    public ArElectronic arElectronic(@RequestParam(name = "token") String token){
        ArUser arUser = JSON.parseObject(redisTemplate.opsForValue().get("user:login" + token), ArUser.class);
        return arElectronicService.getOne(new QueryWrapper<ArElectronic>()
                .eq("uid", arUser.getUid()));
    }
    @PutMapping("/update")
    public Result update(@RequestBody ArElectronic arElectronic){
        System.out.println(arElectronic.getEid()+"eid----------------");
        return Result.build(arElectronicService.updateById(arElectronic), ResultCodeEnum.SUCCESS);
    }
}
